package com.zjq.designpatterns.behaviors.observer.code;/*
 * 版权信息: 北京千⾥马网信科技有限公司</br>
 * Copyright ©2008-2018. All rights reserved. 京ICP备16007318号
 */

import java.util.Observable;

/**
 * 被监控的对象
 * @author jessie
 * @version 1.0
 * @date 2021/1/27
 */
public class Course extends Observable {
    private String courseName;

    public Course(String courseName) {
        this.courseName = courseName;
    }

    public String getCourseName() {
        return courseName;
    }

    public void produceQuestion(Course course, Question question){
        System.out.println(question.getUserName()+"在"+course.getCourseName()+"提交了一个问题");
        setChanged(); //将状态值改变
        notifyObservers(question); //传到teacher
    }
}
